package ee.ttu.serge;

import java.io.IOException;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.List;

import ee.ttu.serge.algo.Fibonacci;

public class Main {

   //http://www.wolframalpha.com/input/?i=%28fibonacci+400%29+%2F+4900+%2F+31536000000
   
   private static final String fileName = "text";
   
   public static void main(String[] args) throws IOException {      
      List<Integer> list = FileHelper.read(fileName + ".in");
      List<Integer> outList = new ArrayList<Integer>();
      for (int i : list) {
         outList.add(Fibonacci.interactive(i));
      }
      FileHelper.write(fileName + ".out", outList);
      System.out.println("Rekursiivne max: " + test1());
   }
   
   public static int test1() {
      long time;
      int max = 0;
      for (int i = 0; i < Integer.MAX_VALUE; i++) {
         time = System.currentTimeMillis();
         BigInteger calls = Fibonacci.recoursive(i, BigInteger.ONE);
         if (System.currentTimeMillis() - time > 4000) {
            return max;
         } else {
            max = i;
            System.out.println(i + " : " + (System.currentTimeMillis() - time) + " : " + calls);
         }
      }
      throw new RuntimeException("Viga mõõtmisega");
   }
  

}
